<?php

namespace App\Db\Connect\Pdo;

class Mysql
{
    public function buildDSN($host, $dbname, $port = 3306, $use_socket = FALSE)
    {
        //mysql:host=localhost;port=3307;dbname=testdb
        //mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
        if ($use_socket)
            return sprintf('mysql:unix_socket=%s;dbname=%s', $host, $dbname);
        else
            return sprintf('mysql:host=%s;port=%d;dbname=%s', $host, $port, $dbname);
    }
}